#include "RingQueue.hpp"
#include<ctime>
#include<unistd.h>
void* Prouductor(void* args)
{
    RingQueue<int> *rq = static_cast<RingQueue<int>*>(args);
    while(1)
    {
        int data = rand() % 10 + 1;
        rq->Push(data);
        cout << "Productor:" << data << endl;

    }
}
void* Consumer(void* args)
{
    RingQueue<int> *rq = static_cast<RingQueue<int>*>(args);
    while(1)
    {
        int data;
        rq->Pop(&data);
        cout << "Consumer:" << data << endl;
        sleep(1);
    }
}
int main()
{
    srand(time(nullptr));
    RingQueue<int> rq(10);
    pthread_t _c1, _p1,_c2,_p2,_c3,_c4;
    pthread_create(&_c1, nullptr, Consumer, &rq);
    pthread_create(&_p2, nullptr, Prouductor, &rq);
    pthread_create(&_p1, nullptr, Prouductor, &rq);
    pthread_create(&_c2, nullptr, Consumer, &rq);
    pthread_create(&_c3, nullptr, Consumer, &rq);
    pthread_create(&_c4, nullptr, Consumer, &rq);
    pthread_join(_c1,nullptr);
    pthread_join(_p1,nullptr);
    return 0;
}